package org.jupiter.blog.api.convertor;

import org.jupiter.blog.api.domain.JupiterUser;
import org.jupiter.blog.api.dto.JupiterUserDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;

@Mapper(componentModel = "spring")
public interface JupiterUserStructConvertor {

	@Mapping(target = "uuid", ignore = true)
	@Mapping(target = "isLocked", ignore = true)
	@Mapping(target = "loginFailCount", ignore = true)
	@Mapping(target = "lastLoginAt", ignore = true)
	@Mapping(target = "lastLoginIp", ignore = true)
	@Mapping(target = "registerIp", ignore = true)
	@Mapping(target = "createTime", ignore = true)
	@Mapping(target = "updateTime", ignore = true)
	@Mapping(target = "deleteTime", ignore = true)
	@Mapping(target = "passwordHash", source = "password")
	JupiterUser toEntity(JupiterUserDTO dto);

	@Mapping(target = "password", source = "passwordHash")
	JupiterUserDTO toDto(JupiterUser user);

	List<JupiterUserDTO> toDtoList(List<JupiterUser> user);
}
